import pandas as pd
import matplotlib.pyplot as plt
import descartes
import geopandas as gpd
from shapely.geometry import Point, Polygon
import plotly.express as px
%matplotlib inline
points = pd.read_csv("D:/KyotoProject/plot/testPoint.csv")
points_1809 = pd.read_csv("D:/KyotoProject/plot/export_plot.csv")
points.head()
points_1809.head()
#Insert unique index in the dataframe
def insertIndex(df, index = 'uid'):
"""trasfer 'uid' in the data to integer unique ID, added into the 'idIndex' column.
df = data frame file
index = the columne name of the dataframe you want to use to generate the unique index, default value = 'uid'
"""
nameList = list(df[index].unique())
print("number of the unique index value: ",len(nameList))
length = len(df)
k = []
for item in range(length):
i = nameList.index(df['uid'][item])
k.append(i)
df['idIndex'] = k
print(df.head())
return df
plot_1809 = insertIndex(points_1809, index = 'uid')
plot_1809.head()
#points_test = points[50:200]
#points_test = points_1809[0:20000]
#select the data points with specific 'idIndex'
filterList = list(range(0,100)) # select the frist 50 idindex of points
points_test = plot_1809[plot_1809['idIndex'].isin(filterList)]
print(len(points_test),'points')
points_test.head()
token = "https://api.mapbox.com/tokens/v2/haomingyang?access_token=sk.eyJ1IjoiaGFvbWluZ3lhbmciLCJhIjoiY2szOGd6OWEwMDhxaTNjcnRxYXl2eXJ1ayJ9.IekZ9PZJeaVKaZqtHGTooQ" # you will need your own token
fig = px.scatter_mapbox(points_test, lat="longitude", lon="latitude", hover_name="idIndex", hover_data=["month", "day", "hour", "minute"],
color_discrete_sequence=["fuchsia"], zoom=6, height=800, color="idIndex", size = "month", size_max = 6, color_continuous_scale=px.colors.cyclical.IceFire)
fig.update_layout(mapbox_style="open-street-map")
#fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
token = "pk.eyJ1IjoiaGFvbWluZ3lhbmciLCJhIjoiY2szOGd2amIyMDllZzNjcWpqNnF6MjU0YyJ9.2dKHbwUYHrGe_V2bv0RXaQ" # you will need your own token
fig = px.scatter_mapbox(points_test, lat="longitude", lon="latitude", hover_name="idIndex", hover_data=["month", "day", "hour", "minute"],
color_discrete_sequence=["fuchsia"], zoom=6, height=1000, color="idIndex", size = "hour", size_max = 5, color_continuous_scale=px.colors.cyclical.IceFire)
#fig.update_layout(mapbox_style="open-street-map")
fig.update_layout(mapbox_style="dark", mapbox_accesstoken=token)
fig.update_layout(margin={"r":0,"t":0,"l":0,"b":0})
fig.show()
import sys
!conda install --yes --prefix {sys.prefix} nbconvert
jupyter nbconvert --to html NOTEBOOK-NAME.ipynb